﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.EntityModel;
using YasharEl.Infrastructure.Core.Locations;
using YasharEl.Infrastructure.ObjectFactory;

namespace YasharEl.Infrastructure.Core.Prototype
{
    [Serializable]
    public abstract class DataType : Enumeration
    {
        #region TypeSafe Static Enumerations

        public static readonly DataType String = new StringDataType();
        public static readonly DataType Long = new LongDataType();
        public static readonly DataType Integer = new IntegerDataType();
        public static readonly DataType Double = new DoubleDataType();
        public static readonly DataType Decimal = new DecimalDataType();
        public static readonly DataType DateTime = new DateTimeDataType();
        public static readonly DataType Boolean = new BooleanDataType();
        public static readonly DataType Address = new AddressDataType();

        #endregion

        #region ReadOnly Fields

        private readonly string dataTypeName;
        private readonly Type clrDataType;

        #endregion

        #region ReadOnly Properties

        public string DataTypeName
        {
            get { return dataTypeName; }
        }

        public Type ClrDataType
        {
            get { return clrDataType; }
        }

        #endregion

        #region Constructors

        protected DataType(int value, string shortName, string longName, string dataTypeName, Type clrDataType)
            : base(value, shortName, longName)
        {
            this.dataTypeName = dataTypeName;
            this.clrDataType = clrDataType;
        }

        protected DataType()
        {
        }

        #endregion

        #region Inner Classes - Type safe concrete enumerations.

        [Serializable]
        private class StringDataType : DataType
        {
            public StringDataType()
                : base(1, "String", "String", "String", typeof(string))
            {

            }
        }

        [Serializable]
        private class LongDataType : DataType
        {
            public LongDataType()
                : base(2, "Long", "Long", "Long", typeof(long))
            {

            }
        }

        [Serializable]
        private class IntegerDataType : DataType
        {
            public IntegerDataType()
                : base(3, "Integer", "Integer", "Integer", typeof(int))
            {

            }
        }

        [Serializable]
        private class DoubleDataType : DataType
        {
            public DoubleDataType()
                : base(4, "Double", "Double", "Double", typeof(double))
            {

            }
        }

        [Serializable]
        private class DecimalDataType : DataType
        {
            public DecimalDataType()
                : base(5, "Decimal", "Decimal", "Decimal", typeof(decimal))
            {

            }
        }

        [Serializable]
        private class DateTimeDataType : DataType
        {
            public DateTimeDataType()
                : base(6, "DateTime", "DateTime", "DateTime", typeof(DateTime))
            {
            }
        }

        [Serializable]
        private class BooleanDataType : DataType
        {
            public BooleanDataType()
                : base(7, "Boolean", "Boolean", "Boolean", typeof(bool))
            {

            }
        }

        [Serializable]
        private class AddressDataType : DataType
        {
            public AddressDataType()
                : base(8, "Address", "Address", "Address", typeof(Address))
            {

            }
        }

        #endregion
    }
}
